package com.qiaoyanqing.ximalaya.discovermodule.discover_adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qiaoyanqing.ximalaya.R;
import com.qiaoyanqing.ximalaya.discovermodule.discover_entity.DiscoverHotShare;
import com.qiaoyanqing.ximalaya.util.CircleTransform;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/12.
 */

public class DiscoverResDisHotShareLVadapter extends BaseAdapter {

    private List<DiscoverHotShare.ListBean> mdata;
    private Context mContext;

    public DiscoverResDisHotShareLVadapter(List<DiscoverHotShare.ListBean> mdata, Context context) {
        this.mdata = mdata;
        mContext = context;
    }

    @Override
    public int getCount() {
        return mdata.size();
    }

    @Override
    public Object getItem(int i) {
        return mdata.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;

        if (view == null) {
            holder=new ViewHolder();
            view= LayoutInflater.from(mContext).inflate(R.layout.hotshare,viewGroup,false);
            holder.mImageView= (ImageView) view.findViewById(R.id.hotimg);
            holder.nickname= (TextView) view.findViewById(R.id.hotnickname);

            holder.Title= (TextView) view.findViewById(R.id.hottitle);
           view.setTag(holder);
        }else {
            holder= (ViewHolder) view.getTag();
        }

        holder.Title.setText(mdata.get(i).getTitle());
        holder.nickname.setText(mdata.get(i).getNickname());
        Picasso.with(mContext).load(mdata.get(i).getCoverSmall()).transform(new CircleTransform()).into(holder.mImageView);

        return view;

    }

    static class ViewHolder{
        private ImageView mImageView;
        private TextView Title,nickname,num;


    }

}
